package com.shardingdemo.snowflake;

import java.util.HashSet;
import java.util.LinkedList;

/**
 * @author chen_lei
 * @date 2020/6/28 11:42
 */
public class IdUtils {
    private static final Snowflake snowflake;

    static {
        snowflake = new Snowflake(10,10);
    }

    public static String generateSnow(){
        return snowflake.nextIdStr();
    }


    public static void main(String[] args) {
        LinkedList<String> list = new LinkedList<String>();
        for (int i = 0; i < 1000000; i++) {
            String s = IdUtils.generateSnow();
            list.addLast(s);
        }

        HashSet<String> set = new HashSet<String>(list);
        if (set.size() != list.size()){
            System.out.println("重复");
        }else {
            System.out.println("没有重复");
        }
    }
}
